<?php

function head(){
	include("templates/header.tpl.html");
}

function foot(){
	include("templates/footer.tpl.html");
}

function front(){
	include("templates/frontpage.tpl.html");
}

function showPoll(){
	$qry_pol = mysql_query("select * from poling where poling_status=1 order by poling_id DESC");
	while ($pol = mysql_fetch_array($qry_pol))
		{	
		echo "<div align='center'><strong>".$pol["poling_title"]."</strong></div>";
		echo "<ul>";
		$qry_count = mysql_query("select sum(poling_item_count) as total from poling_item where poling_item_title=".$pol["poling_id"]);
		$total = mysql_fetch_array($qry_count);
		$qry_pol_sub = mysql_query("select * from poling_item where poling_item_title=".$pol["poling_id"]." order by poling_item_id ASC");
		while ($polsub = mysql_fetch_array($qry_pol_sub))
		{
			if ($polsub["poling_item_count"] > 0)
				$polpersen = (($polsub["poling_item_count"]/$total["total"])*100);
			else 
				$polpersen = 0;
			echo "<li><strong><a href='index.php?pol=1&polid=".$polsub["poling_item_id"]."'><font color=#FFFFFF>".$polsub["poling_item_subtitle"]."</font></a></strong> <SPAN class=text-poll><strong>[".number_format($polpersen,2,',','.')."%]</strong></SPAN></li>";
		}
		echo "</ul>";
	}

}

function showLink(){
	$qry_link = mysql_query("select * from link order by link_name ASC");
	while ($link = mysql_fetch_array($qry_link))
	{
		echo "<div class='link-lain'><a href=".$link["link_url"]." target='_blank'>".$link["link_name"]."</a></div>";
	}

}

function countMe(){
if(!isset($_SESSION["count_visited"])){
	$_SESSION["count_visited"]=session_id();
	$update_count=mysql_query("update counter set counter_count=counter_count+1 where counter_id=1") or die ("Cannot count the visitor..!!");
	$query_count=mysql_query("select counter_count from counter where counter_id=1") or die ("Cannot count the visitor..!!");
	$count=mysql_fetch_array($query_count);
	}else{
	$query_count=mysql_query("select counter_count from counter where counter_id=1") or die ("Cannot count the visitor..!!");
	$count=mysql_fetch_array($query_count);
	print $count["counter_count"];
	}

}


function frontNews(){
$qry_news = mysql_query("select * from news order by news_id DESC limit 0,5");
	while ($news = mysql_fetch_array($qry_news))
	{
		$nw = explode(" ",$news["news_content"]);
		$nnw = "";
		for ($i=0;$i<=30;$i++) $nnw = $nnw." ".$nw[$i];
		$nnw = nl2br($nnw); 
		echo "<TABLE cellSpacing=0 cellPadding=1 width=95% align=center>
			<TBODY><TR><TD><A class=judulberita href=index.php?det=1&kd=news&id=".$news["news_id"].">".$news["news_title"]."</A><BR><SPAN class=text-tanggal>".$news["news_post"]."</SPAN></TD></TR>
			
			<TR><TD><DIV align=justify>".$nnw." ... </DIV></TD></TR>
			<TR><TD>&nbsp;</TD></TR>
			</table>";
	}

}


function listProfile(){
$qry_prof=mysql_query("select * from profil where profil_status=1 order by profil_id ASC");
					while ($prof=mysql_fetch_array($qry_prof))
					{
						echo "<div class='foto'><img class='foto-image' src='".$prof["profil_photo"]."'></div>
						<div align='center'><strong><a href=index.php?det=1&kd=prof&idprof=".$prof["profil_id"].">".$prof["profil_jabatan"]."</a></strong></div>";
					}
}

?>